package com.xuetang9.t9.hotel.mapper;

import com.xuetang9.t9.hotel.beans.EntryFood;
import com.xuetang9.t9.hotel.beans.EntryOrder;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Classname EntryFoodMapper
 * @Description TODO
 * @Date 2020/2/24 15:52
 * @Created by ASUS
 */
public interface EntryFoodMapper {

    @Insert("insert into entryfood (id,foodId,count) values (#{id},#{foodId},${count})")
    int insertEntryFood(@Param("id")Long id ,@Param("foodId")Long foodId,@Param("count")Integer count);

    @Delete("delete from entryfood where id = #{id}")
    int removeEntryFood(@Param("id")Long id);

    @Update("update entryfood set foodId = #{food.id},count = #{count} where id = #{id}")
    int updateEntryFood(EntryFood entryFood);//@Param("id")Long id ,@Param("foodId")Long foodId,@Param("count")Integer count

    @Select("select * from entryfood where id = #{entryOrderId}")
    @Results({
            @Result(column = "foodId",property = "food",one = @One(select = "com.xuetang9.t9.hotel.mapper.EFoodMapper.queryById"))
    })
    List<EntryFood> queryByEntryId(@Param("entryOrderId") Long entryOrderId);
}
